import reducers from "../index";
import { createStore, applyMiddleware } from "redux";
import thunk from "redux-thunk";
function store(initialState) {
  let createStoreWithMiddleware;
  createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
  const store = createStoreWithMiddleware(reducers, initialState);
  if (module.hot) {
    module.hot.accept("../index", () => {
      const nextRootReducer = require("../index");
      store.replaceReducer(nextRootReducer);
    });
  }
  return store;
}

export default store;
